drop database cdcachemyisam_mirPK_mit_FK;
create database cdcachemyisam_mirPK_mit_FK;
use cdcachemyisam_mirPK_mit_FK;

/*==============================================================*/
/* Datenbank MyIsam mit PK mit Ref                              */
/*==============================================================*/

/*==============================================================*/
/* Table: Artists                                               */
/*==============================================================*/
create table artists
(
   artistId             int not null auto_increment,
   name                 varchar(255) not null,
   primary key (artistId)
)
ENGINE = MYISAM;

/*==============================================================*/
/* Table: cds                                                   */
/*==============================================================*/
create table cds
(
   cddbId               bigint not null,
   artistId             int not null REFERENCES artists(artistId),
   title                varchar(255) not null,
   version              int not null,
   numTracks            int not null,
   extd                 text,
   disclen              int not null,
   year                 char(4),
   genreId		int not null REFERENCES genres(genreId),
   primary key (cddbId)
)
ENGINE = MYISAM;

/*==============================================================*/
/* Table: genres                                                */
/*==============================================================*/
create table genres
(
   genreId              int not null,
   genre                varchar(255),
   primary key (genreId)
)
ENGINE = MYISAM;

/*==============================================================*/
/* Table: tracks                                                */
/*==============================================================*/
create table tracks
(
   cddbId               bigint not null REFERENCES cds(cddbId),
   trackNo              int not null,
   offset               int not null,
   title                varchar(255) not null,
   artistId             int REFERENCES artists(artistId),
   extt                 text,
   primary key (cddbId, trackNo)
)
ENGINE = MYISAM;
